import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dark_mode_demo/theme/app_theme_mode.dart';

class ThemeSettingProvider extends ChangeNotifier {
  static const String _kLocalThemeModeKey = "sp_key_app_theme";

  ThemeSettingProvider() {
    int? v = SpUtil.getInt(_kLocalThemeModeKey);
    _mode = AppThemeMode.of(v);
  }

  //当前模式
  AppThemeMode _mode = AppThemeMode.light;
  AppThemeMode get mode => _mode;
  set mode(AppThemeMode value) {
    if (_mode == value) return;

    //修改状态
    _mode = value;
    notifyListeners();
    //更改本地存储
    SpUtil.putInt(_kLocalThemeModeKey, value.value);
  }
}